package Thread_;

class MyThread12 extends Thread{
    @Override
    public void run() {
//        Thread t=Thread.currentThread();
        System.out.println(this.getName());
        System.out.println(this.getId());
    }
}
public class Thread12 {
    //获取当前线程
    public static void main1(String[] args) throws InterruptedException {
        MyThread12 t1 = new MyThread12();
        MyThread12 t2 = new MyThread12();
        t1.start();
        t2.start();

        Thread ma=Thread.currentThread();
        System.out.println("main的ID： "+ma.getId());
        System.out.println("main的Name： "+ma.getName());
        while(true){
            System.out.println("main ");
            Thread.sleep(1000);
        }
    }

    public static void main(String[] args) {
        Thread t=new Thread(()->{
            Thread th=Thread.currentThread();
            System.out.println(th.getId());
            System.out.println(th.getName());
        });
        t.start();

    }
}
